import { defineStore } from 'pinia'
import { getCategory } from '@/server/api/category'
import { CATEGORY_NOMAR_DATA, ALL_CATEGORY } from '@/assets/js/constant.js'

export const useCategoryStore = defineStore('category', {
  state: () => ({
    category: CATEGORY_NOMAR_DATA,
    currentCategory: ALL_CATEGORY,
    index: 0,
    searchText: ''
  }),
  actions: {
    async getCategoryData() {
      const res = (await getCategory()).categorys
      this.category = [ALL_CATEGORY, ...res]
    }
  }
})
